<span page-title>{{ 'Content Views' | translate }}</span>

<div data-extend-template="layouts/table-with-header.html">

  <div data-block="header">
    <h2 translate>Content Views</h2>
  </div>

  <div data-block="list-actions">
    <a class="btn btn-primary" ui-sref="content-views.new" ng-hide="denied('create_content_views')"><i class="pficon pficon-add-circle-o"></i>
      <span translate>Create New View</span>
    </a>
  </div>

  <span data-block="no-rows-message" translate>
    You currently don't have any Content Views.  A Content View can be added by using the button on the right.
  </span>

  <span data-block="no-search-results-message" translate>
    Your search returned zero Content Views.
  </span>

  <div data-block="table">
    <table class="table table-striped table-bordered"
           bst-table="table"
           ng-class="{'table-mask': table.working}">

      <thead>
        <tr bst-table-head>
          <th bst-table-column><span translate>Name</span></th>
          <th bst-table-column><span translate>Composite View?</span></th>
          <th bst-table-column ng-show="importOnlyEnabled()"><span translate>Import-only?</span></th>
          <th bst-table-column><span translate>Last Published</span></th>
          <th bst-table-column><span translate>Environments</span></th>
          <th bst-table-column><span translate>Repositories</span></th>
        </tr>
      </thead>

      <tbody>
        <tr bst-table-row ng-repeat="contentView in table.rows">
          <td bst-table-cell>
            <a ui-sref="content-view.versions({contentViewId: contentView.id})">
              {{ contentView.name }}
            </a>
          </td>
          <td bst-table-cell>
            <span ng-show="contentView.composite" translate>Yes</span>
            <span ng-hide="contentView.composite" translate>No</span>
          </td>
          <td bst-table-cell ng-show="importOnlyEnabled()">
            <span ng-show="contentView.import_only" translate>Yes</span>
            <span ng-hide="contentView.import_only" translate>No</span>
          </td>
          <td bst-table-cell>
            <span ng-show="contentView.last_published"><long-date-time date="contentView.last_published" /></span>
          <span ng-hide="contentView.last_published" translate>
            Not yet published
          </span>
          </td>
          <td bst-table-cell>
          <span ng-show="contentView.environments.length !== 0"
                ng-repeat="environment in contentView.environments" ng-if="environment.permissions.readable">
            {{ environment.name }}<span ng-if="!$last">, </span>
          </span>
          <span ng-show="contentView.environments.length === 0" translate>
            Not yet published
          </span>
          </td>
          <td bst-table-cell class="number-cell">{{ contentView.repositories.length }}</td>
        </tr>
      </tbody>
    </table>
  </div>
</div>
